var e = require("../../requests/newapi.js").getCarNews;

Component({
    properties: {
        ishidden: {
            type: Boolean,
            value: !1
        },
        cateid: {
            type: Number,
            value: 24
        },
        serialid: {
            type: Number,
            value: 2932
        },
        productid: {
            type: Number,
            value: 7
        }
    },
    data: {
        news: [],
        pageindex: 1,
        pagesize: 25,
        isLoading: !0,
        isEmpty: !1,
        defaultimg: "http://res.app.yiche.com/wechatapp/async90x60@2x.png"
    },
    methods: {
        loadmore: function() {
            this.data.isLoading || this.data.isEmpty || (this.setData({
                isLoading: !0
            }), this.getNews());
        },
        getNews: function() {
            var t = this, a = this.data, i = a.cateid, s = a.serialid, n = a.pageindex, d = a.pagesize, r = a.productid, p = a.news;
            e({
                op: "news.list",
                cateid: i,
                serialid: s,
                pageindex: n,
                pagesize: d,
                productid: r
            }).then(function(e) {
                var a = e.Data;
                a && t.setData({
                    pageindex: n + 1,
                    news: p.concat(a),
                    isLoading: !1,
                    isEmpty: a.length < d
                });
            }).catch(function(e) {
                console.log(e);
            });
        },
        jumpToNews: function(e) {
            var t = e.currentTarget.dataset, a = t.newsid, i = t.newstype;
            wx.navigateTo({
                url: "../newsDetail/newsDetail?newsid=" + a + "&newstype=" + i
            });
        },
        handleimgerr: function(e) {
            var t = e.currentTarget.dataset.imgindex, a = this.data.news;
            a[t].PicCover = this.data.defaultimg, this.setData({
                news: a
            });
        }
    }
});